package cn.com.cfae.iras.doc.analyze.components.consistency;

import cn.com.cfae.iras.doc.analyze.components.BaseComponent;
import cn.com.cfae.iras.doc.analyze.components.beans.ComponentResult;
import cn.com.cfae.iras.doc.analyze.handUtil.HandingData;
import cn.com.cfae.iras.doc.analyze.parse.kv.KVText;
import cn.com.cfae.iras.doc.analyze.parse.kv.TextLayout;
import cn.com.cfae.iras.doc.analyze.parse.model.ChapterModel;
import cn.com.cfae.iras.doc.analyze.parse.model.DocumentModel;
import cn.com.cfae.iras.doc.analyze.parse.model.ExtractBizModel;
import cn.com.cfae.iras.doc.analyze.parse.model.ExtractItem;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 信息一致性
 * M-6-1中的3个合并报表和M-6-2中的财务指标分析部分
 * 近三年及一期偿债能力、盈利能力、运营效率等财务指标计算结果是否正确
 * 预评/发行阶段
 */
@Component("U1016")
@Scope("prototype")
public class U1016 extends BaseComponent {
    private static Logger logger = LoggerFactory.getLogger(U1016.class);
    @Autowired
    private HandingData handingData;
    @Override
    public List<ComponentResult> handlerM() {
        logger.info("获取U1016组件M");
        List<ComponentResult> componentResults = checkRulesU1016(getCatalogId(),getCatalogId(),getChapterId(),getRuleTitle());
        return componentResults;
    }

    @Override
    public List<ComponentResult> handlerBM() {
        logger.info("获取U1016组件BM");
        List<ComponentResult> componentResults = checkRulesU1016(getCatalogId(),getCatalogId(),getChapterId(),getRuleTitle());
        return componentResults;
    }

    @Override
    public List<ComponentResult> handlerDM() {
        logger.info("获取U1016组件DM");
        List<ComponentResult> componentResults = checkRulesU1016(getCatalogId(),getCatalogId(),getChapterId(),getRuleTitle());
        return componentResults;
    }
    
    @Override
    public List<ComponentResult> handlerBDM() {
        logger.info("获取U1016组件BDM");
        List<ComponentResult> componentResults = checkRulesU1016(getCatalogId(),getCatalogId(),getChapterId(),getRuleTitle());
        return componentResults;
    }


    private List<ComponentResult> checkRulesU1016(String model,String catalogId,String chapterId,String ruleName){
        DocumentModel extractData = super.getExtractData();
        List<ComponentResult> componentResults = new ArrayList<>();
        ComponentResult componentResult = null;
        ExtractItem extractItem = null;
        int pageNum = 0;
        List<ComponentResult.TextPosition> contentAndPositionList = null;
        boolean flag = false;
        int startPageNum = 0;


        int ylnlPageNum = startPageNum;
        List<ComponentResult.TextPosition> ylnlContentAndPositionList =null;

        int yynlPageNum = startPageNum;
        List<ComponentResult.TextPosition> yynlContentAndPositionList =null;

        int cznlPageNum = startPageNum;
        List<ComponentResult.TextPosition> cznlContentAndPositionList =null;
        try {

            if (extractData!=null){
                ChapterModel chapterModel = extractData.getChapterModel(model);
                startPageNum = chapterModel!=null?chapterModel.getStartPage():0;
                ylnlPageNum = startPageNum;
                yynlPageNum = startPageNum;
                cznlPageNum = startPageNum;
                if (chapterModel!=null){
                    //盈利能力
                    boolean ylnlIsAllRight = true;
                    Map<String, Map<String, ExtractItem>> ylnl = chapterModel.getModel("YLNL").getTables();
                    //获取盈利能力 标题
                    TextLayout ylnlHead = null;
                    ExtractBizModel ylnlModel = chapterModel.getModel("YLNL");
                    if (ylnlModel!=null){
                        ylnlHead = ylnlModel.getTableNameTextLayout();
                    }
                    if (ylnlHead !=null){
                        ylnlContentAndPositionList = new ArrayList<>();
                        ylnlPageNum = ylnlHead.getPageNumber();
                        ylnlPageNum = ylnlPageNum!=0?ylnlPageNum:startPageNum;
                        ComponentResult.TextPosition contentAndPosition = new ComponentResult().new TextPosition();
                        contentAndPosition.setX(ylnlHead.getLeft());
                        contentAndPosition.setY(ylnlHead.getTop());
                        contentAndPosition.setContent(ylnlHead.getText());
                        ylnlContentAndPositionList.add(contentAndPosition);
                    }

                    if (!isEmptyOfMap(ylnl)){
                        Iterator<Map.Entry<String, Map<String, ExtractItem>>> yearEntries = ylnl.entrySet().iterator();
                        List<Integer> yearList = new ArrayList<>();
                        while (yearEntries.hasNext()){
                            Map.Entry<String, Map<String, ExtractItem>> ylnlEntry = yearEntries.next();
                            yearList.add(Integer.parseInt(ylnlEntry.getKey()));
                        }

                        Iterator<Map.Entry<String, Map<String, ExtractItem>>> entries = ylnl.entrySet().iterator();
                        while (entries.hasNext()) {
                            boolean ylnlIsErr = false;
                            boolean isQCCheck = false;
                            Map.Entry<String, Map<String, ExtractItem>> ylnlEntry = entries.next();
                            //资产负债表 （期末）
                            Map<String, ExtractItem> zcfz = chapterModel.getModel("ZCFZ").getTable(ylnlEntry.getKey());

                            //资产负债表 （期初）
                            String year = earlyYear(yearList,ylnlEntry.getKey());
                            Map<String, ExtractItem> qczcfz = null;
                            if (!ylnlEntry.getKey().equals(year)){
                                isQCCheck = true;
                                qczcfz = chapterModel.getModel("ZCFZ").getTable(year);
                            }

                            //利润表
                            Map<String, ExtractItem> lr = chapterModel.getModel("LR").getTable(ylnlEntry.getKey());

                            if (ylnlEntry.getValue()==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"盈利能力表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                ylnlIsErr = true;

                            }
                            if (zcfz==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"资产负债表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                ylnlIsErr = true;
                            }
                            if (lr==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"利润表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                ylnlIsErr = true;
                            }
                            if (ylnlIsErr){
                                if (ylnlIsAllRight){
                                    ylnlIsAllRight = false;
                                }
                                continue;
                            }
                            //营业收入
                            KVText yysr =  lr.get("YYSR")!=null?lr.get("YYSR").getValue():null;
                            String yysrText = yysr!=null?yysr.getText():null;
                            String yysrStr = yysrText;
                            yysrText = moneyFormat(yysrText);

                            //营业成本
                            KVText yycb =  lr.get("YYCB")!=null?lr.get("YYCB").getValue():null;
                            String yycbText = yycb!=null?yycb.getText():null;
                            String yycbStr = yycbText;
                            yycbText = moneyFormat(yycbText);

                            //净利润
                            KVText jlr =  lr.get("JLR")!=null?lr.get("JLR").getValue():null;
                            String jlrText = jlr!=null?jlr.getText():null;
                            String jlrStr =jlrText;
                            jlrText = moneyFormat(jlrText);

                            //税金及附加
                            KVText sjjfj =  lr.get("SJJFJ")!=null?lr.get("SJJFJ").getValue():null;
                            String sjjfjText = sjjfj!=null?sjjfj.getText():null;
                            String sjjfjStr = sjjfjText;
                            sjjfjText = moneyFormat(sjjfjText);


                            //总资产(期末资产合计)
                            KVText zczj = zcfz.get("ZCZJ")!=null?zcfz.get("ZCZJ").getValue():null;
                            String zczjText = zczj!=null?zczj.getText():null;
                            String zczjStr = zczjText;
                            zczjText = moneyFormat(zczjText);


                            //总资产（期初资产合计）
                            KVText qczczj = null;
                            if (isQCCheck){
                                if (qczcfz!=null){
                                    qczczj= qczcfz.get("ZCZJ") != null ? qczcfz.get("ZCZJ").getValue() : null;
                                }
                            }
                            String qczczjText = qczczj != null ? qczczj.getText() : null;
                            String qczczjStr = qczczjText;
                            qczczjText = moneyFormat(qczczjText);


                            //(所有者权益合计) 期末
                            KVText fzhsysqy = zcfz.get("SYZQYHJ")!=null?zcfz.get("SYZQYHJ").getValue():null;
                            String fzhsysqyText = fzhsysqy!=null?fzhsysqy.getText():null;
                            String fzhsysqyStr = fzhsysqyText;
                            fzhsysqyText = moneyFormat(fzhsysqyText);


                            //(所有者权益合计) 期初
                            KVText qcfzhsysqy = null;
                            if (isQCCheck){
                                if (qczcfz!=null){
                                    qcfzhsysqy =  qczcfz.get("SYZQYHJ")!=null?qczcfz.get("SYZQYHJ").getValue():null;
                                }
                            }
                            String qcfzhsysqyText = qcfzhsysqy!=null?qcfzhsysqy.getText():null;
                            String qcfzhsysqyStr = qcfzhsysqyText;
                            qcfzhsysqyText = moneyFormat(qcfzhsysqyText);

                            if (!ylnlEntry.getValue().isEmpty()){
                                Iterator<Map.Entry<String, ExtractItem>> valueEntries = ylnlEntry.getValue().entrySet().iterator();
                                while (valueEntries.hasNext()){
                                    Map.Entry<String, ExtractItem> valueEntry = valueEntries.next();

                                    KVText value = valueEntry.getValue().getValue();
                                    String text = value!=null?value.getText():null;
                                    KVText key = valueEntry.getValue().getKey();
                                    pageNum = key!=null?key.getPageNumber():startPageNum;
                                    pageNum = pageNum!=0?pageNum:startPageNum;
                                    contentAndPositionList = key!=null?getContentAndPositionList(key):null;
                                    String vleuStr = text;
                                    text = moneyFormat(text);


                                    switch (valueEntry.getKey()){
                                        //营业毛利率:（营业收入－营业成本）/营业收入
                                        case "YYMLL":
                                            //营业毛利率
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(yysrText)&&StringUtils.isNotEmpty(yycbText)){
                                                BigDecimal yysrBigDecimal = new BigDecimal(yysrText);
                                                BigDecimal yycbBigDecimal = new BigDecimal(yycbText);
                                                if (isEqualZero(yysrBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "盈利能力指标计算-"+ylnlEntry.getKey()+"营业毛利率", "营业收入为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal subtract =  yysrBigDecimal.subtract(yycbBigDecimal);
                                                    BigDecimal divide = subtract.divide(yysrBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"营业毛利率","营业收入:"+yysrStr+",营业成本:"+yycbStr+",计算的营业毛利率:"+multiply+",抽取的营业毛利率:"+vleuStr+"，财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (ylnlIsAllRight){
                                                            ylnlIsAllRight = false;
                                                        }
                                                    }
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("营业毛利率,");
                                                }
                                                if (StringUtils.isEmpty(yysrText)){
                                                    msg.append("营业收入,");
                                                }
                                                if (StringUtils.isEmpty(yycbText)){
                                                    msg.append("营业成本,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"营业毛利率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (ylnlIsAllRight){
                                                    ylnlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //营业净利率:净利润/营业收入
                                        case "YYJLL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(jlrText)&&StringUtils.isNotEmpty(yysrText)){
                                                BigDecimal jlrBigDecimal = new BigDecimal(jlrText);
                                                BigDecimal yysrbBigDecimal = new BigDecimal(yysrText);

                                                if (isEqualZero(yysrbBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "盈利能力指标计算-"+ylnlEntry.getKey()+"营业净利率", "营业收入为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = jlrBigDecimal.divide(yysrbBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"营业净利率","净利润:"+jlrStr+",营业收入:"+yysrStr+",计算的营业净利率:"+multiply+",抽取的营业净利率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (ylnlIsAllRight){
                                                            ylnlIsAllRight = false;
                                                        }
                                                    }
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("营业净利率,");
                                                }
                                                if (StringUtils.isEmpty(jlrText)){
                                                    msg.append("净利润,");
                                                }
                                                if (StringUtils.isEmpty(yysrText)){
                                                    msg.append("营业收入,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"营业净利率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (ylnlIsAllRight){
                                                    ylnlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //----营业净利润:（营业收入-营业成本-营业税金及附加）/营业收入×100%
                                        //营业利润率:（营业收入-营业成本-营业税金及附加）/营业收入×100%
                                            case "YYLRL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(yysrText)&&StringUtils.isNotEmpty(yycbText)&&StringUtils.isNotEmpty(sjjfjText)){

                                                BigDecimal yysrbBigDecimal = new BigDecimal(yysrText);
                                                BigDecimal yycbBigDecimal = new BigDecimal(yycbText);
                                                BigDecimal sjjfjBigDecimal = new BigDecimal(sjjfjText);

                                                if (isEqualZero(yysrbBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "盈利能力指标计算-"+ylnlEntry.getKey()+"营业利润率", "营业收入为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal subtract = yysrbBigDecimal.subtract(yycbBigDecimal).subtract(sjjfjBigDecimal);
                                                    BigDecimal divide = subtract.divide(yysrbBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"营业利润率","营业收入:"+yysrStr+",营业成本:"+yycbStr+",营业税金及附加:"+sjjfjStr+",计算的营业净利润:"+multiply+",抽取的营业净利润:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (ylnlIsAllRight){
                                                            ylnlIsAllRight = false;
                                                        }
                                                    }
                                                }


                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("营业利润率,");
                                                }
                                                if (StringUtils.isEmpty(yysrText)){
                                                    msg.append("营业收入,");
                                                }
                                                if (StringUtils.isEmpty(yycbText)){
                                                    msg.append("营业成本,");
                                                }
                                                if (StringUtils.isEmpty(sjjfjText)){
                                                    msg.append("营业税金及附加,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"营业利润率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (ylnlIsAllRight){
                                                    ylnlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //总资产报酬率:净利润/年末总资产
                                        case "ZZCBCL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(jlrText)&&StringUtils.isNotEmpty(zczjText)){

                                                BigDecimal jlrBigDecimal = new BigDecimal(jlrText);
                                                BigDecimal zczjBigDecimal = new BigDecimal(zczjText);

                                                if (isEqualZero(zczjBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "盈利能力指标计算-"+ylnlEntry.getKey()+"总资产报酬率", "年末总资产为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = jlrBigDecimal.divide(zczjBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"总资产报酬率","净利润:"+jlrStr+",年末总资产:"+zczjStr+",计算的总资产报酬率:"+multiply+",抽取的总资产报酬率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (ylnlIsAllRight){
                                                            ylnlIsAllRight = false;
                                                        }
                                                    }
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("总资产报酬率,");
                                                }
                                                if (StringUtils.isEmpty(jlrText)){
                                                    msg.append("净利润,");
                                                }
                                                if (StringUtils.isEmpty(zczjText)){
                                                    msg.append("年末总资产,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"总资产报酬率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (ylnlIsAllRight){
                                                    ylnlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //----净资产收益率:净利润/年末所有者权益
                                        //净资产收益率:净利润/average（期初所有者权益合计，期末所有者权益合计）
                                        case "JZCSYL":
                                            if (isQCCheck){
                                                if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(jlrText)&&StringUtils.isNotEmpty(fzhsysqyText)&&StringUtils.isNotEmpty(qcfzhsysqyText)){
                                                    BigDecimal jlrBigDecimal = new BigDecimal(jlrText);
                                                    BigDecimal fzhsysqyBigDecimal = new BigDecimal(fzhsysqyText);
                                                    BigDecimal qcfzhsysqyBigDecimal = new BigDecimal(qcfzhsysqyText);
                                                    BigDecimal add = fzhsysqyBigDecimal.add(qcfzhsysqyBigDecimal).divide(new BigDecimal("2"),6,BigDecimal.ROUND_HALF_UP);
                                                    if (isEqualZero(add)){
                                                        componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "盈利能力指标计算-"+ylnlEntry.getKey()+"净资产收益率", "年末所有者权益为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                        componentResults.add(componentResult);
                                                    }else {
                                                        BigDecimal divide = jlrBigDecimal.divide(add, 6, BigDecimal.ROUND_HALF_UP);
                                                        BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                        BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                        if (textBigDecimal.compareTo(multiply)!=0){
                                                            componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"净资产收益率","净利润:"+jlrStr+",期末所有者权益:"+fzhsysqyStr+",期初所有者权益:"+qcfzhsysqyStr+",计算的净资产收益率:"+multiply+",抽取的净资产收益率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                            componentResults.add(componentResult);
                                                            if (ylnlIsAllRight){
                                                                ylnlIsAllRight = false;
                                                            }
                                                        }
                                                    }


                                                }else {
                                                    StringBuffer msg = new StringBuffer();
                                                    if (StringUtils.isEmpty(text)){
                                                        msg.append("净资产收益率,");
                                                    }
                                                    if (StringUtils.isEmpty(jlrText)){
                                                        msg.append("净利润,");
                                                    }
                                                    if (StringUtils.isEmpty(fzhsysqyText)){
                                                        msg.append("期末所有者权益,");
                                                    }
                                                    if (StringUtils.isEmpty(qcfzhsysqyText)){
                                                        msg.append("期初所有者权益,");
                                                    }
                                                    msg.append("未抽取到,建议人工核对");
                                                    componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"净资产收益率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                    componentResults.add(componentResult);
                                                    if (ylnlIsAllRight){
                                                        ylnlIsAllRight = false;
                                                    }
                                                }
                                            }


                                            break;
                                            //总资产收益率 :净利润/average（期初资产合计，期末资产合计）
                                        case "ZZCSYL":
                                            if (isQCCheck){

                                                if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(zczjText)&&StringUtils.isNotEmpty(qczczjText)&&StringUtils.isNotEmpty(jlrText)){

                                                    BigDecimal zczjBigDecimal = new BigDecimal(zczjText);
                                                    BigDecimal qczczjBigDecimal = new BigDecimal(qczczjText);
                                                    BigDecimal jlrBigDecimal = new BigDecimal(jlrText);

                                                    BigDecimal add = qczczjBigDecimal.add(zczjBigDecimal).divide(new BigDecimal("2"),6,BigDecimal.ROUND_HALF_UP);
                                                    if (isEqualZero(add)){
                                                        componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "盈利能力指标计算-"+ylnlEntry.getKey()+"总资产收益率", "期初与期末资产合计平均值为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                        componentResults.add(componentResult);
                                                    }else {
                                                        BigDecimal divide = jlrBigDecimal.divide(add,6,BigDecimal.ROUND_HALF_UP);
                                                        BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                        BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                        if (textBigDecimal.compareTo(multiply)!=0){
                                                            componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"总资产收益率","净利润:"+jlrStr+",期初资产合计:"+qczczjStr+",期末资产合计:"+zczjStr+",计算的总资产收益率:"+multiply+",抽取的总资产收益率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                            componentResults.add(componentResult);
                                                            if (ylnlIsAllRight){
                                                                ylnlIsAllRight = false;
                                                            }
                                                        }
                                                    }


                                                }else {
                                                    StringBuffer msg = new StringBuffer();
                                                    if (StringUtils.isEmpty(text)){
                                                        msg.append("总资产收益率,");
                                                    }
                                                    if (StringUtils.isEmpty(jlrText)){
                                                        msg.append("净利润,");
                                                    }
                                                    if (StringUtils.isEmpty(qczczjText)){
                                                        msg.append("期初资产合计,");
                                                    }
                                                    if (StringUtils.isEmpty(zczjText)){
                                                        msg.append("期末资产合计,");
                                                    }
                                                    msg.append("未抽取到,建议人工核对");
                                                    componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-"+ylnlEntry.getKey()+"总资产收益率","参与计算数据未识别,建议人工核对",true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                    componentResults.add(componentResult);
                                                    if (ylnlIsAllRight){
                                                        ylnlIsAllRight = false;
                                                    }
                                                }
                                            }
                                            break;
                                    }
                                }
                            }

                        }

                        if (ylnlIsAllRight){
                            componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算","合理",false,getRegulationId(),ylnlPageNum,ylnlContentAndPositionList,"01");
                            componentResults.add(componentResult);
                        }

                    }else {
                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算-盈利能力表数据","未抽取到,建议人工核对",true,getRegulationId(),ylnlPageNum,ylnlContentAndPositionList,"03");
                        componentResults.add(componentResult);
                    }

                    //运营效率
                    boolean yynlIsAllRight = true;
                    Map<String, Map<String, ExtractItem>> yynl = chapterModel.getModel("YYNL").getTables();

                    //获取运营效率 标题
                    TextLayout yynlHead = null;
                    ExtractBizModel yynlModel = chapterModel.getModel("YYNL");
                    if (yynlModel!=null){
                        yynlHead = yynlModel.getTableNameTextLayout();
                    }
                    if (yynlHead !=null){
                        yynlContentAndPositionList = new ArrayList<>();
                        yynlPageNum = yynlHead.getPageNumber();
                        yynlPageNum = yynlPageNum!=0?yynlPageNum:startPageNum;
                        ComponentResult.TextPosition contentAndPosition = new ComponentResult().new TextPosition();
                        contentAndPosition.setX(yynlHead.getLeft());
                        contentAndPosition.setY(yynlHead.getTop());
                        contentAndPosition.setContent(yynlHead.getText());
                        yynlContentAndPositionList.add(contentAndPosition);
                    }

                    if (!isEmptyOfMap(yynl)){

                        Iterator<Map.Entry<String, Map<String, ExtractItem>>> entries = yynl.entrySet().iterator();

                        //获取最小年,因为要去前一年的数据，所以不用算
                        List<Integer> yearList = new ArrayList<>();
                        while (entries.hasNext()){
                            Map.Entry<String, Map<String, ExtractItem>> yynlEntry = entries.next();
                            yearList.add(Integer.parseInt(yynlEntry.getKey()));
                        }
                        int smallyear = 0;
                        if (CollectionUtils.isNotEmpty(yearList)){
                            smallyear=yearList.get(0);
                            for (int i=1;i<yearList.size();i++){
                                if (smallyear>yearList.get(i)){
                                    smallyear = yearList.get(i);
                                }
                            }
                        }
                        Iterator<Map.Entry<String, Map<String, ExtractItem>>> entriess = yynl.entrySet().iterator();

                        while (entriess.hasNext()) {
                            boolean yyxlIsErr = false;
                            Map.Entry<String, Map<String, ExtractItem>> yynlEntry = entriess.next();
                            //最小年不计算
                            if (yynlEntry.getKey().equals(String.valueOf(smallyear))){
                                continue;
                            }

                            //资产负债表
                            Map<String, ExtractItem> zcfz = chapterModel.getModel("ZCFZ").getTable(yynlEntry.getKey());
                            String year = earlyYear(yearList,yynlEntry.getKey());
                            Map<String, ExtractItem> zqzcfz = null;//之前一年的 即期初
                            if (StringUtils.isNotEmpty(year)){
                                zqzcfz = chapterModel.getModel("ZCFZ").getTable(year);
                            }

                            //利润表
                            Map<String, ExtractItem> lr = chapterModel.getModel("LR").getTable(yynlEntry.getKey());

                            if (yynlEntry.getValue()==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"运营效率表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                yyxlIsErr = true;
                            }
                            if (zcfz==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"期末资产负债表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                yyxlIsErr = true;
                            }
                            if (zqzcfz==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"期初资产负债表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                yyxlIsErr = true;
                            }
                            if (lr==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"利润表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                yyxlIsErr = true;
                            }
                            if (yyxlIsErr){
                                if (yynlIsAllRight){
                                    yynlIsAllRight = false;
                                }
                                continue;
                            }
                            //期末应收账款
                            KVText qmyspjjyszk =  zcfz.get("YSZK")!=null?zcfz.get("YSZK").getValue():null;
                            String qmyspjjyszkText = qmyspjjyszk!=null?qmyspjjyszk.getText():null;
                            String qmyspjjyszkStr = qmyspjjyszkText;
                            qmyspjjyszkText = moneyFormat( qmyspjjyszkText);

                            //期初应收账款
                            KVText qcyspjjyszk =  zqzcfz.get("YSZK")!=null?zqzcfz.get("YSZK").getValue():null;
                            String qcyspjjyszkText = qcyspjjyszk!=null?qcyspjjyszk.getText():null;
                            String qcyspjjyszkStr =qcyspjjyszkText;
                            qcyspjjyszkText = moneyFormat(qcyspjjyszkText);


                            //营业收入
                            KVText yysr =  lr.get("YYSR")!=null?lr.get("YYSR").getValue():null;
                            String yysrText = yysr!=null?yysr.getText():null;
                            String yysrStr = yysrText;
                            yysrText = moneyFormat(yysrText);



                            //期初存货

                            KVText qcch =  zqzcfz.get("CH")!=null?zqzcfz.get("CH").getValue():null;
                            String qcchText = qcch!=null?qcch.getText():null;
                            String qcchStr = qcchText;
                            qcchText = moneyFormat(qcchText);

                            //期末存货
                            KVText qmch =  zcfz.get("CH")!=null?zcfz.get("CH").getValue():null;
                            String qmchText = qmch!=null?qmch.getText():null;
                            String qmchStr = qmchText;
                            qmchText = moneyFormat(qmchText);


                            //期初资产合计
                            KVText qczczj =  zqzcfz.get("ZCZJ")!=null?zqzcfz.get("ZCZJ").getValue():null;
                            String qczczjText = qczczj!=null?qczczj.getText():null;
                            String qczczjStr =qczczjText;
                            qczczjText = moneyFormat(qczczjText);


                            //期末资产合计
                            KVText qmzczj =  zcfz.get("ZCZJ")!=null?zcfz.get("ZCZJ").getValue():null;
                            String qmzczjText = qmzczj!=null?qmzczj.getText():null;
                            String qmzczjStr =  qmzczjText;
                            qmzczjText = moneyFormat(qmzczjText);


                            //营业成本
                            KVText yycb =  lr.get("YYCB")!=null?lr.get("YYCB").getValue():null;
                            String yycbText = yycb!=null?yycb.getText():null;
                            String yycbStr = yycbText;
                            yycbText = moneyFormat(yycbText);


                            if (!yynlEntry.getValue().isEmpty()){
                                Iterator<Map.Entry<String, ExtractItem>> valueEntries = yynlEntry.getValue().entrySet().iterator();


                                while (valueEntries.hasNext()){
                                    Map.Entry<String, ExtractItem> valueEntry = valueEntries.next();
                                    KVText value = valueEntry.getValue().getValue();
                                    KVText key = valueEntry.getValue().getKey();
                                    String text = value!=null?value.getText():null;
                                    pageNum = key!=null?key.getPageNumber():startPageNum;
                                    pageNum = pageNum!=0?pageNum:startPageNum;
                                    contentAndPositionList = key!=null?getContentAndPositionList(key):null;
                                    String vleuStr = text;
                                    text = moneyFormat(text);


                                    switch (valueEntry.getKey()){
                                        //应收账款周转率:营业收入/average（期初应收账款，期末应收账款）
                                        case "YSZKZZL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(qcyspjjyszkText)&&StringUtils.isNotEmpty(qmyspjjyszkText)&&StringUtils.isNotEmpty(yysrText)){

                                                BigDecimal qcyspjjyszkBigDecimal = new BigDecimal(qcyspjjyszkText);
                                                BigDecimal qmyspjjyszkBigDecimal = new BigDecimal(qmyspjjyszkText);
                                                BigDecimal yysrBigDecimal = new BigDecimal(yysrText);

                                                BigDecimal add = qcyspjjyszkBigDecimal.add(qmyspjjyszkBigDecimal).divide(new BigDecimal("2"),6,BigDecimal.ROUND_HALF_UP);

                                                if (isEqualZero(add)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "运营效率指标计算-"+yynlEntry.getKey()+"应收账款周转率", "期初与期末应收账款平均值为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = yysrBigDecimal.divide(add, 2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(divide)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"应收账款周转率","营业收入:"+yysrStr+",期初应收账款:"+qcyspjjyszkStr+",期末应收账款:"+qmyspjjyszkStr+",计算的应收账款周转率:"+divide+",抽取的应收账款周转率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (yynlIsAllRight){
                                                            yynlIsAllRight = false;
                                                        }
                                                    }
                                                    /*BigDecimal divide = yysrBigDecimal.divide(add, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"应收账款周转率","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                    }*/
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("应收账款周转率,");
                                                }
                                                if (StringUtils.isEmpty(yysrText)){
                                                    msg.append("营业收入,");
                                                }
                                                if (StringUtils.isEmpty(qcyspjjyszkText)){
                                                    msg.append("期初应收账款,");
                                                }
                                                if (StringUtils.isEmpty(qmyspjjyszkText)){
                                                    msg.append("期末应收账款,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"应收账款周转率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (yynlIsAllRight){
                                                    yynlIsAllRight = false;
                                                }
                                            }

                                            break;

                                        //应收账款周转天数:360/应收账款周转率
                                        case "YSZKZZTS":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(qcyspjjyszkText)&&StringUtils.isNotEmpty(qmyspjjyszkText)&&StringUtils.isNotEmpty(yysrText)) {

                                                BigDecimal qcyspjjyszkBigDecimal = new BigDecimal(qcyspjjyszkText);
                                                BigDecimal qmyspjjyszkBigDecimal = new BigDecimal(qmyspjjyszkText);
                                                BigDecimal yysrBigDecimal = new BigDecimal(yysrText);

                                                BigDecimal add = qcyspjjyszkBigDecimal.add(qmyspjjyszkBigDecimal).divide(new BigDecimal("2"),6,BigDecimal.ROUND_HALF_UP);

                                                if (isEqualZero(add)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "运营效率指标计算-"+yynlEntry.getKey()+"应收账款周转天数", "期初与期末应收账款平均值为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = yysrBigDecimal.divide(add, 6, BigDecimal.ROUND_HALF_UP);
                                                    //BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal day = new BigDecimal("360").divide(divide, 2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);

                                                    if (textBigDecimal.compareTo(day) !=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"应收账款周转天数","营业收入:"+yysrStr+",期初应收账款:"+qcyspjjyszkStr+",期末应收账款:"+qmyspjjyszkStr+",计算的应收账款周转天数:"+day+",抽取的应收账款周转天数:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (yynlIsAllRight){
                                                            yynlIsAllRight = false;
                                                        }
                                                    }
                                                    /*BigDecimal divide = yysrBigDecimal.divide(add, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal day = new BigDecimal("360").divide(multiply, 2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);

                                                    if (textBigDecimal.compareTo(day) !=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"应收账款周转天数","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                    }*/
                                                }


                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("应收账款周转天数,");
                                                }
                                                if (StringUtils.isEmpty(yysrText)){
                                                    msg.append("营业收入,");
                                                }
                                                if (StringUtils.isEmpty(qcyspjjyszkText)){
                                                    msg.append("期初应收账款,");
                                                }
                                                if (StringUtils.isEmpty(qmyspjjyszkText)){
                                                    msg.append("期末应收账款,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"应收账款周转天数",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (yynlIsAllRight){
                                                    yynlIsAllRight = false;
                                                }
                                            }

                                            break;

                                        //存货周转率:营业成本/average（期初存货，期末存货）
                                        case "CHZZL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(yycbText)&&StringUtils.isNotEmpty(qcchText)&&StringUtils.isNotEmpty(qmchText)){

                                                BigDecimal qcchBigDecimal = new BigDecimal(qcchText);
                                                BigDecimal qmchBigDecimal = new BigDecimal(qmchText);
                                                BigDecimal yycbBigDecimal = new BigDecimal(yycbText);

                                                BigDecimal add = qcchBigDecimal.add(qmchBigDecimal).divide(new BigDecimal("2"), 6, BigDecimal.ROUND_HALF_UP);

                                                if (isEqualZero(add)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "运营效率指标计算-"+yynlEntry.getKey()+"存货周转率", "期初与期末存货平均值为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = yycbBigDecimal.divide(add,2, BigDecimal.ROUND_HALF_UP);
                                                    //BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(divide)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"存货周转率","营业成本:"+yycbStr+",期初存货:"+qcchStr+",期末存货:"+qmchStr+",计算的存货周转率:"+divide+",抽取的存货周转率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (yynlIsAllRight){
                                                            yynlIsAllRight = false;
                                                        }
                                                    }
                                                    /*BigDecimal divide = yycbBigDecimal.divide(add,6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"存货周转率","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                    }*/
                                                }


                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("存货周转率,");
                                                }
                                                if (StringUtils.isEmpty(yycbText)){
                                                    msg.append("营业成本,");
                                                }
                                                if (StringUtils.isEmpty(qcchText)){
                                                    msg.append("期初存货,");
                                                }
                                                if (StringUtils.isEmpty(qmchText)){
                                                    msg.append("期末存货,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"存货周转率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (yynlIsAllRight){
                                                    yynlIsAllRight = false;
                                                }
                                            }


                                            break;
                                        //存货周转天数:360/存货周转率
                                        case "CHZZTS":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(yycbText)&&StringUtils.isNotEmpty(qcchText)&&StringUtils.isNotEmpty(qmchText)){

                                                BigDecimal qcchBigDecimal = new BigDecimal(qcchText);
                                                BigDecimal qmchBigDecimal = new BigDecimal(qmchText);
                                                BigDecimal yycbBigDecimal = new BigDecimal(yycbText);
                                                BigDecimal add = qcchBigDecimal.add(qmchBigDecimal).divide(new BigDecimal("2"), 6, BigDecimal.ROUND_HALF_UP);

                                                if (isEqualZero(add)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "运营效率指标计算-"+yynlEntry.getKey()+"存货周转天数", "期初与期末存货平均值为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = yycbBigDecimal.divide(add,6, BigDecimal.ROUND_HALF_UP);
                                                    //BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal day = new BigDecimal("360").divide(divide, 2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(day)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"存货周转天数","营业成本:"+yycbStr+",期初存货:"+qcchStr+",期末存货:"+qmchStr+",计算的存货周转天数:"+day+",抽取的存货周转天数:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (yynlIsAllRight){
                                                            yynlIsAllRight = false;
                                                        }
                                                    }
                                                    /*BigDecimal divide = yycbBigDecimal.divide(add,6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal day = new BigDecimal("360").divide(multiply, 2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(day)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"存货周转天数","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                    }*/
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("存货周转天数,");
                                                }
                                                if (StringUtils.isEmpty(yycbText)){
                                                    msg.append("营业成本,");
                                                }
                                                if (StringUtils.isEmpty(qcchText)){
                                                    msg.append("期初存货,");
                                                }
                                                if (StringUtils.isEmpty(qmchText)){
                                                    msg.append("期末存货,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"存货周转天数",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (yynlIsAllRight){
                                                    yynlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //营业周期:应收账款周转天数＋存货周转天数
                                        case "YYZQ":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(qcyspjjyszkText)&&StringUtils.isNotEmpty(qmyspjjyszkText)&&StringUtils.isNotEmpty(yysrText)&&StringUtils.isNotEmpty(qmchText)&&StringUtils.isNotEmpty(qcchText)){
                                                boolean yszkFlag = false;
                                                boolean chzqFlag = false;

                                                BigDecimal qcyspjjyszkBigDecimal = new BigDecimal(qcyspjjyszkText);
                                                BigDecimal qmyspjjyszkBigDecimal = new BigDecimal(qmyspjjyszkText);
                                                BigDecimal yysrBigDecimal = new BigDecimal(yysrText);
                                                BigDecimal yszkAdd = qcyspjjyszkBigDecimal.add(qmyspjjyszkBigDecimal).divide(new BigDecimal("2"),6,BigDecimal.ROUND_HALF_UP);
                                                if (isEqualZero(yszkAdd)){
                                                    yszkFlag = true;
                                                }

                                                BigDecimal qcchBigDecimal = new BigDecimal(qcchText);
                                                BigDecimal qmchBigDecimal = new BigDecimal(qmchText);
                                                BigDecimal yycbBigDecimal = new BigDecimal(yycbText);
                                                BigDecimal chAdd = qcchBigDecimal.add(qmchBigDecimal).divide(new BigDecimal("2"), 6, BigDecimal.ROUND_HALF_UP);
                                                if (isEqualZero(chAdd)){
                                                   chzqFlag = true;
                                                }

                                                if (yszkFlag && chzqFlag){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "运营效率指标计算-"+yynlEntry.getKey()+"营业周期", "期初与期末存货平均值,应收账款平均值为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                    break;
                                                }else if (yszkFlag&&!chzqFlag){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "运营效率指标计算-"+yynlEntry.getKey()+"营业周期", "期初与期末应收账款平均值为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                    break;
                                                }else if (!yszkFlag&&chzqFlag){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "运营效率指标计算-"+yynlEntry.getKey()+"营业周期", "期初与期末存货平均值为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                    break;
                                                }
                                                //应收账款周转天数
                                                BigDecimal yszkDivide = yysrBigDecimal.divide(yszkAdd, 6, BigDecimal.ROUND_HALF_UP);
                                                //BigDecimal yszkMultiply = yszkDivide.multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
                                                BigDecimal yszkDay = new BigDecimal("360").divide(yszkDivide, 6, BigDecimal.ROUND_HALF_UP);

                                                //存货周转天数
                                                BigDecimal chDivide = yycbBigDecimal.divide(chAdd,6, BigDecimal.ROUND_HALF_UP);
                                               // BigDecimal chMultiply = chDivide.multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
                                                BigDecimal chDay = new BigDecimal("360").divide(chDivide, 6, BigDecimal.ROUND_HALF_UP);


                                                //和
                                                BigDecimal add = yszkDay.add(chDay).setScale(2, BigDecimal.ROUND_HALF_UP);

                                                BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);

                                                if (textBigDecimal.compareTo(add)!=0){
                                                    componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"营业周期","营业收入:"+yysrStr+",期初应收账款:"+qcyspjjyszkStr+",期末应收账款:"+qmyspjjyszkStr+",营业成本:"+yycbStr+",期初存货:"+qcchStr+",期末存货:"+qmchStr+",计算的营业周期:"+add+",抽取的营业周期:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                    componentResults.add(componentResult);
                                                    if (yynlIsAllRight){
                                                        yynlIsAllRight = false;
                                                    }
                                                }
                                                /*//应收账款周转天数
                                                BigDecimal yszkDivide = yysrBigDecimal.divide(yszkAdd, 6, BigDecimal.ROUND_HALF_UP);
                                                BigDecimal yszkMultiply = yszkDivide.multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
                                                BigDecimal yszkDay = new BigDecimal("360").divide(yszkMultiply, 6, BigDecimal.ROUND_HALF_UP);

                                                //存货周转天数
                                                BigDecimal chDivide = yycbBigDecimal.divide(chAdd,6, BigDecimal.ROUND_HALF_UP);
                                                BigDecimal chMultiply = chDivide.multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP);
                                                BigDecimal chDay = new BigDecimal("360").divide(chMultiply, 6, BigDecimal.ROUND_HALF_UP);


                                                //和
                                                BigDecimal add = yszkDay.add(chDay).setScale(2, BigDecimal.ROUND_HALF_UP);

                                                BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);

                                                if (textBigDecimal.compareTo(add)!=0){
                                                    componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"营业周期","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                    componentResults.add(componentResult);
                                                }*/


                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("营业周期,");
                                                }
                                                if (StringUtils.isEmpty(qcchText)){
                                                    msg.append("期初存货,");
                                                }
                                                if (StringUtils.isEmpty(qmchText)){
                                                    msg.append("期末存货,");
                                                }
                                                if (StringUtils.isEmpty(yysrText)){
                                                    msg.append("营业收入,");
                                                }
                                                if (StringUtils.isEmpty(qcyspjjyszkText)){
                                                    msg.append("期初应收账款,");
                                                }
                                                if (StringUtils.isEmpty(qmyspjjyszkText)){
                                                    msg.append("期末应收账款,");
                                                }

                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"营业周期",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (yynlIsAllRight){
                                                    yynlIsAllRight = false;
                                                }
                                            }


                                            break;
                                        //总资产周转率:营业收入/average（期初资产合计，期末资产合计）
                                        case "ZZCZZL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(yysrText)&&StringUtils.isNotEmpty(qczczjText)&&StringUtils.isNotEmpty(qmzczjText)){

                                                BigDecimal yysrBigDecimal = new BigDecimal(yysrText);
                                                BigDecimal qczczjBigDecimal = new BigDecimal(qczczjText);
                                                BigDecimal qmzczjBigDecimal = new BigDecimal(qmzczjText);

                                                BigDecimal add = qczczjBigDecimal.add(qmzczjBigDecimal).divide(new BigDecimal("2"), 6,BigDecimal.ROUND_HALF_UP);

                                                if (isEqualZero(add)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "运营效率指标计算-"+yynlEntry.getKey()+"总资产周转率", "期初与期末资产合计平均值为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = yysrBigDecimal.divide(add,2, BigDecimal.ROUND_HALF_UP);
                                                    //BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(divide)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"总资产周转率","营业收入:"+yysrStr+",期初资产合计:"+qczczjStr+",期末资产合计:"+qmzczjStr+",计算的总资产周转率:"+divide+",抽取的总资产周转率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (yynlIsAllRight){
                                                            yynlIsAllRight = false;
                                                        }
                                                    }
                                                    /*BigDecimal divide = yysrBigDecimal.divide(add,6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"总资产周转率","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                    }*/
                                                }

                                            }
                                            else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("总资产周转率,");
                                                }
                                                if (StringUtils.isEmpty(yysrText)){
                                                    msg.append("营业收入,");
                                                }
                                                if (StringUtils.isEmpty(qczczjText)){
                                                    msg.append("期初资产合计,");
                                                }
                                                if (StringUtils.isEmpty(qmzczjText)){
                                                    msg.append("期末资产合计,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-"+yynlEntry.getKey()+"总资产周转率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (yynlIsAllRight){
                                                    yynlIsAllRight = false;
                                                }
                                            }

                                            break;

                                    }
                                }
                            }
                        }

                        if (yynlIsAllRight){
                            componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算","合理",false,getRegulationId(),yynlPageNum,yynlContentAndPositionList,"01");
                            componentResults.add(componentResult);
                        }
                    }else {
                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算-运营效率表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                        componentResults.add(componentResult);
                    }


                    //偿债能力
                    boolean cznlIsAllRight = true;
                    Map<String, Map<String, ExtractItem>> cznl = chapterModel.getModel("CZNL").getTables();

                    //偿债能力 标题
                    TextLayout cznlHead = null;
                    ExtractBizModel cznlModel = chapterModel.getModel("CZNL");
                    if (cznlModel!=null){
                        cznlHead = cznlModel.getTableNameTextLayout();
                    }
                    if (cznlHead !=null){
                        cznlContentAndPositionList = new ArrayList<>();
                        cznlPageNum = cznlHead.getPageNumber();
                        cznlPageNum = cznlPageNum!=0?cznlPageNum:startPageNum;
                        ComponentResult.TextPosition contentAndPosition = new ComponentResult().new TextPosition();
                        contentAndPosition.setX(cznlHead.getLeft());
                        contentAndPosition.setY(cznlHead.getTop());
                        contentAndPosition.setContent(cznlHead.getText());
                        cznlContentAndPositionList.add(contentAndPosition);
                    }

                    if (!isEmptyOfMap(cznl)){
                        Iterator<Map.Entry<String, Map<String, ExtractItem>>> entries = cznl.entrySet().iterator();
                        while (entries.hasNext()) {
                            boolean cznlIsErr = false;
                            Map.Entry<String, Map<String, ExtractItem>> cznlEntry = entries.next();
                            //利润表
                            Map<String, ExtractItem> lr = chapterModel.getModel("LR").getTable(cznlEntry.getKey());
                            //现金流量表
                            Map<String, ExtractItem> xjll = chapterModel.getModel("XJLL").getTable(cznlEntry.getKey());
                            //资产负债表
                            Map<String, ExtractItem> zcfz = chapterModel.getModel("ZCFZ").getTable(cznlEntry.getKey());

                            if (cznlEntry.getValue()==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"偿债能力表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                cznlIsErr = true;
                            }
                            if (xjll==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"现金流量表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                cznlIsErr = true;
                            }
                            if (zcfz==null){
                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"资产负债表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                                componentResults.add(componentResult);
                                cznlIsErr = true;
                            }
                            if (cznlIsErr){
                                if (cznlIsAllRight){
                                    cznlIsAllRight = false;
                                }
                                continue;
                            }

                            //流动资产合计
                            KVText ldzchj = zcfz.get("LDZCHJ")!=null?zcfz.get("LDZCHJ").getValue():null;
                            String ldzchjText = ldzchj!=null?ldzchj.getText():null;
                            String ldzchjStr = ldzchjText;
                            ldzchjText = moneyFormat(ldzchjText);


                            //流动负债合计
                            KVText ldfzhj = zcfz.get("LDFZHJ")!=null?zcfz.get("LDFZHJ").getValue():null;
                            String ldfzhjText = ldfzhj!=null?ldfzhj.getText():null;
                            String ldfzhjStr = ldfzhjText;
                            ldfzhjText = moneyFormat(ldfzhjText);


                            //存货
                            KVText ch = zcfz.get("CH")!=null?zcfz.get("CH").getValue():null;
                            String chText = ch!=null?ch.getText():null;
                            String chStr = chText;
                            chText = moneyFormat(chText);


                            //负债合计
                            KVText fzhj = zcfz.get("FZHJ")!=null?zcfz.get("FZHJ").getValue():null;
                            String fzhjText = fzhj!=null?fzhj.getText():null;
                            String fzhjStr = fzhjText;
                            fzhjText = moneyFormat(fzhjText);


                            // 资产合计
                            KVText zczj = zcfz.get("ZCZJ")!=null?zcfz.get("ZCZJ").getValue():null;
                            String zczjText = zczj!=null?zczj.getText():null;
                            String zczjStr = zczjText;
                            zczjText = moneyFormat(zczjText);



                            //经营活动现金流量净额
                            KVText jyhdcsxjllje = xjll.get("JYHDCSXJLLJE")!=null?xjll.get("JYHDCSXJLLJE").getValue():null;
                            String jyhdcsxjlljeText = jyhdcsxjllje!=null?jyhdcsxjllje.getText():null;
                            String jyhdcsxjlljeStr = jyhdcsxjlljeText;
                            jyhdcsxjlljeText = moneyFormat(jyhdcsxjlljeText);


                            //所有者权益合计
                            KVText syzqyhj = zcfz.get("SYZQYHJ")!=null?zcfz.get("SYZQYHJ").getValue():null;
                            String syzqyhjText = syzqyhj!=null?syzqyhj.getText():null;
                            String syzqyhjStr = syzqyhjText;
                            syzqyhjText = moneyFormat(syzqyhjText);


                            //无形资产
                            KVText wxzc = zcfz.get("WXZC")!=null?zcfz.get("WXZC").getValue():null;
                            String wxzcText = wxzc!=null?wxzc.getText():null;
                            String wxzcStr = wxzcText;
                            wxzcText = moneyFormat(wxzcText);


                            //短期借款
                            KVText dqjk = zcfz.get("DQJK")!=null?zcfz.get("DQJK").getValue():null;
                            String dqjkText = dqjk!=null?dqjk.getText():null;
                            String dqjkStr = dqjkText;
                            dqjkText = moneyFormat(dqjkText);


                            //交易性金融负债（其他流动负债）
                            KVText qtldfz = zcfz.get("QTLDFZ")!=null?zcfz.get("QTLDFZ").getValue():null;
                            String qtldfzText = qtldfz!=null?qtldfz.getText():null;
                            String qtldfzStr = qtldfzText;
                            qtldfzText = moneyFormat(qtldfzText);


                            //应付票据
                            KVText yfpj = zcfz.get("YFPJ")!=null?zcfz.get("YFPJ").getValue():null;
                            String yfpjText = yfpj!=null?yfpj.getText():null;
                            String yfpjStr = yfpjText;
                            yfpjText = moneyFormat(yfpjText);


                            //一年内到期的非流动负债
                            KVText ynndqfldzc = zcfz.get("YNNDQFLDFZ")!=null?zcfz.get("YNNDQFLDFZ").getValue():null;
                            String ynndqfldzcText = ynndqfldzc!=null?ynndqfldzc.getText():null;
                            String ynndqfldzcStr = ynndqfldzcText;
                            ynndqfldzcText = moneyFormat(ynndqfldzcText);


                            //长期借款
                            KVText cqjk = zcfz.get("CQJK")!=null?zcfz.get("CQJK").getValue():null;
                            String cqjkText = cqjk!=null?cqjk.getText():null;
                            String cqjkStr = cqjkText;
                            cqjkText = moneyFormat(cqjkText);



                            //应付债券
                            KVText yfzq = zcfz.get("YFZQ")!=null?zcfz.get("YFZQ").getValue():null;
                            String yfzqText = yfzq!=null?yfzq.getText():null;
                            String yfzqStr =yfzqText;
                            yfzqText = moneyFormat(yfzqText);


                            //营业收入
                            KVText yysr =  lr.get("YYSR")!=null?lr.get("YYSR").getValue():null;
                            String yysrText = yysr!=null?yysr.getText():null;
                            String yysrStr = yysrText;
                            yysrText = moneyFormat(yysrText);


                            if (!cznlEntry.getValue().isEmpty()){
                                Iterator<Map.Entry<String, ExtractItem>> valueEntries = cznlEntry.getValue().entrySet().iterator();
                                while (valueEntries.hasNext()){
                                    Map.Entry<String, ExtractItem> valueEntry = valueEntries.next();
                                    KVText value = valueEntry.getValue().getValue();
                                    KVText key = valueEntry.getValue().getKey();
                                    String text = value!=null?value.getText():null;
                                    pageNum = key!=null?key.getPageNumber():startPageNum;
                                    pageNum = pageNum!=0?pageNum:startPageNum;
                                    contentAndPositionList = key!=null?getContentAndPositionList(key):null;
                                    String vleuStr = text;
                                    text = moneyFormat(text);


                                    switch (valueEntry.getKey()){
                                        //流动比率：流动资产合计/流动负债合计
                                        case "LDBL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(ldzchjText)&&StringUtils.isNotEmpty(ldfzhjText)){


                                                BigDecimal ldzchjBigDecimal = new BigDecimal(ldzchjText);
                                                BigDecimal ldfzhjBigDecimal = new BigDecimal(ldfzhjText);
                                                if (isEqualZero(ldfzhjBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "偿债能力指标计算-"+cznlEntry.getKey()+"流动比率", "流动负债合计为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = ldzchjBigDecimal.divide(ldfzhjBigDecimal, 2, BigDecimal.ROUND_HALF_UP);
                                                   // BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(divide)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"流动比率","流动资产合计:"+ldzchjStr+",流动负债合计:"+ldfzhjStr+",计算的流动比率:"+divide+",抽取的流动比率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (cznlIsAllRight){
                                                            cznlIsAllRight = false;
                                                        }
                                                    }
                                                    /*BigDecimal divide = ldzchjBigDecimal.divide(ldfzhjBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"流动比率","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                    }*/
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("流动比率,");
                                                }
                                                if (StringUtils.isEmpty(ldzchjText)){
                                                    msg.append("流动资产合计,");
                                                }
                                                if (StringUtils.isEmpty(ldfzhjText)){
                                                    msg.append("流动负债合计,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"流动比率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //速动比率：（流动资产合计－存货）/流动负债合计
                                        case "SDBL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(ldfzhjText)&StringUtils.isNotEmpty(chText)&&StringUtils.isNotEmpty(ldzchjText)){

                                                BigDecimal ldzchjBigDecimal = new BigDecimal(ldzchjText);
                                                BigDecimal chBigDecimal = new BigDecimal(chText);
                                                BigDecimal ldfzhjBigDecimal = new BigDecimal(ldfzhjText);

                                                if (isEqualZero(ldfzhjBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "偿债能力指标计算-"+cznlEntry.getKey()+"速动比率", "流动负债合计为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = ldzchjBigDecimal.subtract(chBigDecimal).divide(ldfzhjBigDecimal, 2, BigDecimal.ROUND_HALF_UP);
                                                    //BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(divide)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"速动比率","流动资产合计:"+ldzchjStr+",存货:"+chStr+",流动负债合计:"+ldfzhjStr+",计算的速动比率:"+divide+",抽取的速动比率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (cznlIsAllRight){
                                                            cznlIsAllRight = false;
                                                        }
                                                    }
                                                   /* BigDecimal divide = ldzchjBigDecimal.subtract(chBigDecimal).divide(ldfzhjBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"速动比率","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                    }*/
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("速动比率,");
                                                }
                                                if (StringUtils.isEmpty(ldzchjText)){
                                                    msg.append("流动资产合计,");
                                                }
                                                if (StringUtils.isEmpty(chText)){
                                                    msg.append("存货,");
                                                }
                                                if (StringUtils.isEmpty(ldfzhjText)){
                                                    msg.append("流动负债合计,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"速动比率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }


                                            break;
                                        //资产负债率：负债合计/资产合计
                                        case "ZCFZL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(fzhjText)&&StringUtils.isNotEmpty(zczjText)){

                                                BigDecimal fzhjBigDecimal = new BigDecimal(fzhjText);
                                                BigDecimal zchjBigDecimal = new BigDecimal(zczjText);
                                                if (isEqualZero(zchjBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "偿债能力指标计算-"+cznlEntry.getKey()+"资产负债率", "资产合计为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = fzhjBigDecimal.divide(zchjBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"资产负债率","负债合计:"+fzhjStr+",资产合计:"+zczjStr+",计算的资产负债率:"+multiply+",抽取的资产负债率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (cznlIsAllRight){
                                                            cznlIsAllRight = false;
                                                        }
                                                    }
                                                }

                                            }else {

                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("资产负债率,");
                                                }
                                                if (StringUtils.isEmpty(fzhjText)){
                                                    msg.append("负债合计,");
                                                }
                                                if (StringUtils.isEmpty(zczjText)){
                                                    msg.append("资产合计,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"资产负债率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //现金流动负债比：经营活动现金流量净额/流动负债合计
                                        case "XJLDFZB":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(jyhdcsxjlljeText)&&StringUtils.isNotEmpty(ldfzhjText)){

                                                BigDecimal jyhdcsxjlljeBigDecimal = new BigDecimal(jyhdcsxjlljeText);
                                                BigDecimal ldfzhjBigDecimal = new BigDecimal(ldfzhjText);
                                                if (isEqualZero(ldfzhjBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "偿债能力指标计算-"+cznlEntry.getKey()+"现金流动负债比", "流动负债合计为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = jyhdcsxjlljeBigDecimal.divide(ldfzhjBigDecimal, 2, BigDecimal.ROUND_HALF_UP);
                                                    //BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(divide)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"现金流动负债比","经营活动现金流量净额:"+jyhdcsxjlljeStr+",流动负债合计:"+ldfzhjStr+",计算的现金流动负债比:"+divide+",抽取的现金流动负债比:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (cznlIsAllRight){
                                                            cznlIsAllRight = false;
                                                        }
                                                    }
                                                    /*BigDecimal divide = jyhdcsxjlljeBigDecimal.divide(ldfzhjBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"现金流动负债比","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                    }*/
                                                }


                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("现金流动负债比,");
                                                }
                                                if (StringUtils.isEmpty(jyhdcsxjlljeText)){
                                                    msg.append("经营活动现金流量净额,");
                                                }
                                                if (StringUtils.isEmpty(ldfzhjText)){
                                                    msg.append("流动负债合计,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"现金流动负债比",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }
                                            break;

                                        //现金负债总额比：经营活动现金流量净额/负债合计
                                        case "XJFZZEB":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(jyhdcsxjlljeText)&&StringUtils.isNotEmpty(fzhjText)) {

                                                BigDecimal jyhdcsxjlljeBigDecimal = new BigDecimal(jyhdcsxjlljeText);
                                                BigDecimal fzhjBigDecimal = new BigDecimal(fzhjText);

                                                if (isEqualZero(fzhjBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "偿债能力指标计算-"+cznlEntry.getKey()+"现金负债总额比", "负债合计为0无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = jyhdcsxjlljeBigDecimal.divide(fzhjBigDecimal, 2, BigDecimal.ROUND_HALF_UP);
                                                    //BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);

                                                    if (textBigDecimal.compareTo(divide)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"现金负债总额比","经营活动现金流量净额:"+jyhdcsxjlljeStr+",负债合计:"+fzhjStr+",计算的现金负债总额比:"+divide+",抽取的现金负债总额比:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (cznlIsAllRight){
                                                            cznlIsAllRight = false;
                                                        }
                                                    }
                                                    /*BigDecimal divide = jyhdcsxjlljeBigDecimal.divide(fzhjBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);

                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"现金负债总额比","财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                    }*/
                                                }


                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("现金负债总额比,");
                                                }
                                                if (StringUtils.isEmpty(jyhdcsxjlljeText)){
                                                    msg.append("经营活动现金流量净额,");
                                                }
                                                if (StringUtils.isEmpty(fzhjText)){
                                                    msg.append("负债合计,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"现金负债总额比",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }

                                            break;

                                        //有形净值债务率：负债合计/（所有者权益合计－无形资产）
                                        case "YXJZZWL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(fzhjText)&&StringUtils.isNotEmpty(syzqyhjText)&&StringUtils.isNotEmpty(wxzcText)) {


                                                BigDecimal syzqyhjBigDecimal = new BigDecimal(syzqyhjText);
                                                BigDecimal wxzcBigDecimal = new BigDecimal(wxzcText);
                                                BigDecimal fzhjBigDecimal = new BigDecimal(fzhjText);

                                                BigDecimal subtract = syzqyhjBigDecimal.subtract(wxzcBigDecimal);
                                                if (isEqualZero(subtract)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "偿债能力指标计算-"+cznlEntry.getKey()+"有形净值债务率", "所有者权益合计与无形资产差值为0,无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = fzhjBigDecimal.divide(subtract, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);

                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"有形净值债务率","负债合计:"+fzhjStr+",所有者权益合计:"+syzqyhjStr+",无形资产:"+wxzcStr+",计算的有形净值债务率:"+multiply+",抽取的有形净值债务率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (cznlIsAllRight){
                                                            cznlIsAllRight = false;
                                                        }
                                                    }
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("有形净值债务率,");
                                                }
                                                if (StringUtils.isEmpty(syzqyhjText)){
                                                    msg.append("所有者权益合计,");
                                                }
                                                if (StringUtils.isEmpty(fzhjText)){
                                                    msg.append("负债合计,");
                                                }
                                                if (StringUtils.isEmpty(wxzcText)){
                                                    msg.append("无形资产,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"有形净值债务率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //EBIT
                                        case "EBIT":
                                            break;
                                        //利息保障倍数
                                        case "LXBZBS":
                                            break;
                                        //EBITDA
                                        case "EBITDA":
                                            break;
                                        //债务保护倍数
                                        case "ZWBHBS":
                                            break;
                                        //短期债务：短期借款+交易性金融负债（其他流动负债）+应付票据+一年内到期的非流动负债
                                        case "DQZW":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isEmpty(dqjkText)&&StringUtils.isNotEmpty(qtldfzText)&&StringUtils.isNotEmpty(yfpjText)&&StringUtils.isNotEmpty(ynndqfldzcText)){

                                                BigDecimal dqjkBigDecimal = new BigDecimal(dqjkText);
                                                BigDecimal qtldfzBigDecimal = new BigDecimal(qtldfzText);
                                                BigDecimal yfpjBigDecimal = new BigDecimal(yfpjText);
                                                BigDecimal ynndqfldzcBigDecimal = new BigDecimal(ynndqfldzcText);

                                                BigDecimal add = dqjkBigDecimal.add(qtldfzBigDecimal).add(yfpjBigDecimal).add(ynndqfldzcBigDecimal).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                if (textBigDecimal.compareTo(add)!=0){
                                                    componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"短期债务","短期借款:"+dqjkStr+",其他流动负债:"+qtldfzStr+",应付票据:"+yfpjStr+",一年内到期的非流动负债:"+ynndqfldzcStr+",计算的短期债务:"+add+",抽取的短期债务:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                    componentResults.add(componentResult);
                                                    if (cznlIsAllRight){
                                                        cznlIsAllRight = false;
                                                    }
                                                }

                                            }else {

                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("短期债务,");
                                                }
                                                if (StringUtils.isEmpty(dqjkText)){
                                                    msg.append("短期借款,");
                                                }
                                                if (StringUtils.isEmpty(qtldfzText)){
                                                    msg.append("交易性金融负债(其他流动负债),");
                                                }
                                                if (StringUtils.isEmpty(yfpjText)){
                                                    msg.append("应付票据,");
                                                }
                                                if (StringUtils.isEmpty(ynndqfldzcText)){
                                                    msg.append("一年内到期的非流动负债,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"短期债务",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }

                                            break;

                                        //长期债务：长期借款＋应付债券
                                        case "CQZW":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(cqjkText)&&StringUtils.isNotEmpty(yfzqText)){
                                                BigDecimal cqjkBigDecimal = new BigDecimal(cqjkText);
                                                BigDecimal yfzqBigDecimal = new BigDecimal(yfzqText);

                                                BigDecimal add = cqjkBigDecimal.add(yfzqBigDecimal).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                if (textBigDecimal.compareTo(add)!=0){
                                                    componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"长期债务","长期借款:"+cqjkStr+",应付债券:"+yfzqStr+",计算的长期债务:"+add+",抽取的长期债务:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                    componentResults.add(componentResult);
                                                    if (cznlIsAllRight){
                                                        cznlIsAllRight = false;
                                                    }
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("长期债务,");
                                                }
                                                if (StringUtils.isEmpty(cqjkText)){
                                                    msg.append("长期借款,");
                                                }
                                                if (StringUtils.isEmpty(yfzqText)){
                                                    msg.append("应付债券,");
                                                }

                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"长期债务",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //销售现金比率：经营活动现金流量净额/营业收入
                                        case "XSXJBL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(jyhdcsxjlljeText)&&StringUtils.isNotEmpty(yysrText)){

                                                BigDecimal jyhdcsxjlljeBigDecimal = new BigDecimal(jyhdcsxjlljeText);
                                                BigDecimal yysrBigDecimal = new BigDecimal(yysrText);

                                                if (isEqualZero(yysrBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "偿债能力指标计算-"+cznlEntry.getKey()+"销售现金比率", "营业收入为0,无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = jyhdcsxjlljeBigDecimal.divide(yysrBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"销售现金比率","经营活动现金流量净额:"+jyhdcsxjlljeStr+",营业收入:"+yysrStr+",计算的销售现金比率:"+multiply+",抽取的销售现金比率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (cznlIsAllRight){
                                                            cznlIsAllRight = false;
                                                        }
                                                    }
                                                }


                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("销售现金比率,");
                                                }
                                                if (StringUtils.isEmpty(jyhdcsxjlljeText)){
                                                    msg.append("经营活动现金流量净额,");
                                                }
                                                if (StringUtils.isEmpty(yysrText)){
                                                    msg.append("营业收入,");
                                                }

                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"销售现金比率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //全部资产现金回收率：经营活动现金流量净额/资产合计
                                        case "QBZCXJHSL":
                                            if (StringUtils.isNotEmpty(text)&&StringUtils.isNotEmpty(jyhdcsxjlljeText)&&StringUtils.isNotEmpty(zczjText)){

                                                BigDecimal jyhdcsxjlljeBigDecimal = new BigDecimal(jyhdcsxjlljeText);
                                                BigDecimal zczjBigDecimal = new BigDecimal(zczjText);

                                                if (isEqualZero(zczjBigDecimal)){
                                                    componentResult = handingData.getComponentResult(catalogId,chapterId, ruleName, "偿债能力指标计算-"+cznlEntry.getKey()+"全部资产现金回收率", "资产合计为0,无法计算", true, getRegulationId(), pageNum, contentAndPositionList, "03");
                                                    componentResults.add(componentResult);
                                                }else {
                                                    BigDecimal divide = jyhdcsxjlljeBigDecimal.divide(zczjBigDecimal, 6, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal multiply = divide.multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                                                    BigDecimal textBigDecimal = new BigDecimal(text).setScale(2,BigDecimal.ROUND_HALF_UP);
                                                    if (textBigDecimal.compareTo(multiply)!=0){
                                                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"全部资产现金回收率","经营活动现金流量净额:"+jyhdcsxjlljeStr+",资产合计:"+zczjStr+",计算的全部资产现金回收率:"+multiply+",抽取的全部资产现金回收率:"+vleuStr+",财务指标计算有误",true,getRegulationId(),pageNum,contentAndPositionList,"02");
                                                        componentResults.add(componentResult);
                                                        if (cznlIsAllRight){
                                                            cznlIsAllRight = false;
                                                        }
                                                    }
                                                }

                                            }else {
                                                StringBuffer msg = new StringBuffer();
                                                if (StringUtils.isEmpty(text)){
                                                    msg.append("全部资产现金回收率,");
                                                }
                                                if (StringUtils.isEmpty(jyhdcsxjlljeText)){
                                                    msg.append("经营活动现金流量净额,");
                                                }
                                                if (StringUtils.isEmpty(zczjText)){
                                                    msg.append("资产合计,");
                                                }
                                                msg.append("未抽取到,建议人工核对");
                                                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-"+cznlEntry.getKey()+"全部资产现金回收率",msg.toString(),true,getRegulationId(),pageNum,contentAndPositionList,"03");
                                                componentResults.add(componentResult);
                                                if (cznlIsAllRight){
                                                    cznlIsAllRight = false;
                                                }
                                            }

                                            break;
                                        //EBITDA利息倍数
                                        case "EBITDA_LXBS":
                                            break;
                                    }
                                }
                            }
                        }
                        if (cznlIsAllRight){
                            componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算","合理",false,getRegulationId(),cznlPageNum,cznlContentAndPositionList,"01");
                            componentResults.add(componentResult);
                        }

                    }else {
                        componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算-偿债能力表数据","未抽取到,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                        componentResults.add(componentResult);
                    }
                }else {
                    componentResults.clear();
                    componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算","未识别,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                    componentResults.add(componentResult);
                    componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算","未识别,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                    componentResults.add(componentResult);
                    componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算","未识别,建议人工核对",true,getRegulationId(),startPageNum,null,"03");
                    componentResults.add(componentResult);
                }
            }



           /* if (CollectionUtils.isEmpty(componentResults)){
                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算","合理",false,getRegulationId(),cznlPageNum,cznlContentAndPositionList,"01");
                componentResults.add(componentResult);
                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算","合理",false,getRegulationId(),ylnlPageNum,ylnlContentAndPositionList,"01");
                componentResults.add(componentResult);
                componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算","合理",false,getRegulationId(),yynlPageNum,yynlContentAndPositionList,"01");
                componentResults.add(componentResult);
            }*/

        }catch (Exception e){
            componentResults.clear();
            componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"偿债能力指标计算","未识别,建议人工核对",true,getRegulationId(),startPageNum,contentAndPositionList,"03");
            componentResults.add(componentResult);
            componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"盈利能力指标计算","未识别,建议人工核对",true,getRegulationId(),startPageNum,contentAndPositionList,"03");
            componentResults.add(componentResult);
            componentResult =  handingData.getComponentResult(catalogId,chapterId,ruleName,"运营效率指标计算","未识别,建议人工核对",true,getRegulationId(),startPageNum,contentAndPositionList,"03");
            componentResults.add(componentResult);
            logger.error(e.getMessage(),e);
        }
        return componentResults;
    }


    private String earlyYear(List<Integer> yearList,String currentYear){
        String year = null;
        List<Integer> years = yearList;
        int index = 0;
        if (CollectionUtils.isEmpty(years))
            return year;
        Collections.sort(years);
        if (years.contains(Integer.parseInt(currentYear))){
            index = years.indexOf(Integer.parseInt(currentYear));
        }
        if (index-1<0){
            index = 0;
        }else {
            index = index -1;
        }
        year = String.valueOf(years.get(index));
        return year;
    }

    private String moneyFormat(String text){
        if (StringUtils.isEmpty(text)){
            return null;
        }
        String regex ="(-)?[0-9]";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(text);
        if (!matcher.find()){
            return null;
        }

        //text = text.replaceAll("\\s+", "");
        /*String regex = ".*\\d+.*";
        Pattern pattern = Pattern.compile(regex);
        Matcher m = pattern.matcher(text);
        if (m.matches()){
            if (text.contains(",")){
                text = text.replaceAll(",","");
            }
            if (text.contains("%")){
                text = text.replaceAll("%","");
            }
        }else {
            return null;
        }
        return text;*/
        return StringFilter(text);
    }

    private boolean isEqualZero(BigDecimal value){
        if (value.compareTo(new BigDecimal("0"))==0){
            return true;
        }
        return false;
    }

    private Boolean isEmptyOfMap(Map<String, Map<String, ExtractItem>> table ){
        if (table==null||table.isEmpty()){
            return true;
        }else {
            for (String key :table.keySet()){
                if (table.get(key)==null||table.get(key).isEmpty()){
                    return true;
                }
                break;
            }
        }
        return false;
    }


    private String StringFilter(String str) {
    // 清除掉所有特殊字符
        String regEx="[`~!@#$%^&*()+=|{}':;',\\[\\]<>/?~！@#￥%……&*（）——+|{}【】‘；：”“’。，、？\\s+]";
        Pattern p = Pattern.compile(regEx);
        Matcher m = p.matcher(str);
        return m.replaceAll("").trim();
    }
}
